let lastOptionTime = new Date().getTime();
let currentTime = new Date().getTime();
let timeOut = 30 * 60 * 1000;


window.onload = function () {
    window.document.onmousedown = function () {
        let token = window.localStorage.getItem('token');
        lastOptionTime = Number(window.localStorage.getItem('lastOptionTime'))
        if (token && lastOptionTime) {
            currentTime = new Date().getTime() 
            if (currentTime - lastOptionTime > timeOut) {
                window.localStorage.clear();
                if (window.location.pathname == '/login') return
                window.location.pathname = '/login'
            } else {
                window.localStorage.setItem('lastOptionTime', new Date().getTime().toString())
            }
        } else {
            window.localStorage.setItem('lastOptionTime', new Date().getTime().toString())
        }
    }
}


export { }